package cn.linjianhui.article.model;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class CommonResult<T> {
    private String code;
    private String msg;
    private T data;

    public CommonResult() {

    }

    public CommonResult(String code, String msg, T data) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public static <T> CommonResult<T> success(T data) {
        return new CommonResult<T>("200", "操作成功", data);
    }

    public static <T> CommonResult<T> error() {
        return new CommonResult<T>("500", "操作失败", null);
    }

    public static <T> CommonResult<T> error(String code, String msg) {
        return new CommonResult<T>(code, msg, null);
    }
}
